from django.contrib import admin
from .models import Family, FamilyMember

@admin.register(Family)
class FamilyAdmin(admin.ModelAdmin):
    list_display = ('name', 'created_by', 'status', 'member_count', 'active_member_count', 'last_activity_at')
    list_filter = ('status', 'created_at')
    search_fields = ('name', 'created_by__username')
    readonly_fields = ('member_count', 'active_member_count', 'last_activity_at', 'health_record_count')

@admin.register(FamilyMember)
class FamilyMemberAdmin(admin.ModelAdmin):
    list_display = ('user', 'family', 'role', 'relation', 'contribution_score', 'shared_record_count')
    list_filter = ('role', 'family', 'joined_at')
    search_fields = ('user__username', 'family__name', 'relation')
    readonly_fields = ('last_seen_at', 'contribution_score', 'shared_record_count')